﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>条码档案信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/Content/X-admin/css/font.css" rel="stylesheet" />
    <script src="~/Content/X-admin/lib/layui/layui.js"></script>
    <link href="~/Content/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/Content/X-admin/js/jquery.min.js"></script>
    <script src="~/Content/X-admin/js/xadmin.js"></script>
    <script src="~/Content/Scripts/System/systemFrame.js"></script>
    <script src="~/Content/Scripts/System/Common.js"></script>
    <script type="text/html" id="barDemo">
        <a title="数据明细" href="javascript:;" lay-event="view"><i class="layui-icon">&#xe647;</i></a>
    </script>

</head>
<body>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <div class="layui-inline layui-show-xs-block">
                            <div class="layui-inline layui-show-xs-block">
                           
                             
                                <button class="layui-btn" lay-filter="btnSubmit" id="btnSubmit" type="button" onclick="sureChoose()"><i class="layui-icon">&#xe64d;</i>取消占用</button>
                            </div>
   

                        </div>
                    </div>
                    <div class="layui-card-body layui-table-body layui-table-main">
                        <table class="layui-hide" id="list" lay-filter="list"></table>

                    </div>
         
                </div>
            </div>
        </div>
    </div>
</body>

</html>

<script>
    var barCodes = "";
    /**
    数据加载
    **/
    function loadData() {
        var sdata = JSON.stringify(FormToJson("dForm"));
        layui.use('table', function () {
            var table = layui.table;
            table.render({
                elem: '#list'
            , cols: [[ //标题栏
              { type: 'checkbox' }
            , { field: 'barCode', title: '条码', width: 130 }
            , { field: 'plCode', title: '关联计划', width: 120 }
                , { field: 'userName', title: '占用人员', width: 110, }
            , { field: 'createtime', title: '占用时间', width: 160 }
            ]], done: function (res, curr, count) {

            }
            , url: "../Bar/GetDataList?dataType=bzy&condition=" + barCode
            , skin: 'row' //表格风格
            , even: true
            , page: true //是否显示分页
            , limits: [30, 40, 50]
            , limit: 40 //每页默认显示的数量
            });
            //监听工具条
            table.on('checkbox(list)', function (obj) {
                var data = obj.data;

                //为父窗口input赋值
                barCodes = "";
                var checkStatus = table.checkStatus('list');
                var infos = "";
                for (var i = 0; i < checkStatus.data.length; i++) {
                    infos = infos + checkStatus.data[i].barCode + ",";
                }
                barCodes = infos.substr(0, infos.length - 1);
            });
     
        });
    }

    var barCode = "";
    $(function () {
        //获取列表
        barCode = getUrlVariable("barCode");
        $("input[ name='barCode']").val(barCode);
        if (barCode != "") {
            loadData();
        }
    })

    /**
    确认选择
    **/
    function sureChoose() {
        if (barCodes == "") {
            layer.msg("没有选择任何数据"); return;
        } else {
            $.ajax({
                url: "../Bar/DropZhanYong",
                data: { barCodes: barCodes },
                dataType: "json",
                type: "POST",
                success: function (rsl) {
                    if (rsl.Result) {
                        layer.msg("取消占用成功");
                        var index = parent.layer.getFrameIndex(window.name);
                        //关闭当前frame
                        parent.layer.close(index);
                    } else {
                        layer.msg(rsl.Message); return;
                    }
                }
            });


        }
    }

</script>